$(document).ready(function(){
	var ctx = $("#ctx").val();//获取服务器地址
	$('#dateChoose_span a').click(function(e){
      	inputForDate(e,$(this),$('#dateRangePicker'));
        $("#dateTab").val($(this).attr("value"));
        $(this).addClass('dateChange').siblings('.dateChange').removeClass('dateChange');
    });
if($('#dateRangePicker').attr("type")!="hidden"){
	$('#dateRangePicker').dateRangePicker();
}
	if($('#dateRangePicker').val() == ""){
		$('#dateRangePicker').val(getlastDate(1)+" to "+getlastDate(1));
		$("#date #today").addClass('dateChange');
		$("#dateTab").val("today");
	}
	
	$('#dateChoose_span a').each(function(){
		var value = $(this).attr("value");
		if($("#dateTab").val() == value){
			$(this).addClass('dateChange');
		}
	});
	//点击日期控件的按钮时，去掉前面时间标签的样式
	$(".apply-btn").click(function(){
		if(!$(this).hasClass("disabled")){
			$("#dateTab").val("");
			$('#dateChoose_span a').removeClass('dateChange');
			$('#dateRangePicker').val($(".start-day").text() +" to "+$(".end-day").text());
		}
	});
	
	var colspanTotal = parseInt($("#colspanTotal").val());
	if($("#operatorIds").val() == ""){
		$(".hidden-operator").hide();
		colspanTotal = colspanTotal - 1;
		$("#colspanTotal").val(colspanTotal);
		$("#total").attr("colspan",colspanTotal);
	}else{
		$(".hidden-operator").show();
		$(".tbodyTrheji").css("display","");
	}
	if($("#zoneIds").val() == ""){
		$(".hidden-zone").hide();
		colspanTotal = colspanTotal - 1;
		$("#total").attr("colspan",colspanTotal);
	}else{
		$(".hidden-zone").show();
		$(".tbodyTrheji").css("display","");
	}
	if($("#osIds").val() == ""){
		$(".hidden-os").hide();
		colspanTotal = colspanTotal - 1;
		$("#colspanTotal").val(colspanTotal);
		$("#total").attr("colspan",colspanTotal);
	}else{
		$(".hidden-os").show();
		$(".tbodyTrheji").css("display","");
	}
		
	$("#btn_formSubmit").click(function(){
		var timepicker1val=$('#timepicker1').val();
	    var timepicker2val=$('#timepicker2').val();
	    var val1=timepicker1val.split(":");
	    var val2=timepicker2val.split(":");
	    if(val1[0]>val2[0]){
	    	alert("后者必须大于前者，请重新选择")
	    }else if(val1[0]==val2[0]){
	    	if(val1[1]>val2[1]){
	    		alert("后者必须大于前者，请重新选择")
	    	}else{
	    		$('#myform').submit();
	    	}	
	    }else{
	    	$('#myform').submit();
	    }
	});
	// 分页中超链接跳转
	$('#pagecontent .pagination ul li a[href]').click(function(){
		var _page = $(this).attr('href').substr(1);
		var _form = $('#myform');
		_form.find('input:hidden[name="page"]').val(_page);
		_form.submit();
		return false;
	});
});